package book.ch9;

import javax.swing.*;

class MyMenuFrame extends JFrame{
    public MyMenuFrame(String s,int x,int y,int w,int h){
        setTitle(s);
        setLocation(x,y);
        setSize(w,h);

        JMenuBar menuBar=new JMenuBar();
        setJMenuBar(menuBar);

        JMenu fruitMenu=new JMenu("水果菜单");

        menuBar.add(fruitMenu);

        JMenuItem banana=new JMenuItem("香蕉");
        fruitMenu.add(banana);

        JMenu apple=new JMenu("苹果");
        fruitMenu.add(apple);

        JMenuItem fushiApple=new JMenuItem("红富士");
        fushiApple.setIcon(new ImageIcon("C:\\Users\\lqcone\\Pictures\\Saved Pictures\\ptdc.jfif"));
        apple.add(fushiApple);
        JMenuItem hnApple=new JMenuItem("花牛");
        apple.add(hnApple);


        setVisible(true);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    }
}
public class E9_2 {
    public static void main(String[] args) {
        MyMenuFrame myframe=new MyMenuFrame("菜单窗口演示",20,30,600,290);
    }
}
